Repository navigation
Python translation of NREL SPA code - #48
Conversation
|
This is very cool and very well done. To be clear, @alorenzo175 used NREL's paper, not their code, to make this. |
|
Would have liked to comment on the diff, but my computer/browser chokes on long diffs... On
I also suggest that the function Would like to hear others input on the above (cc @Calama-Consulting @bmu). In
|
|
This is great!! (I tried to do this myself a while ago, but I gave up after a while!) One question: |
I would recommend that spa_numpy is the default. Numba can take a few seconds to compile and the numpy code is pretty fast. If someone is doing a lot of calculations and needs the speed, they can specify the use of numba and many threads.
I thought changing 'spa' to something else, but I didn't want to break the API. I think we should all agree on if/how to change it.
Good idea. |
It is definitely possible to separate out the time calculations. I'll play around with it a little to see the best way to do it. |
52a428b to
64cc8d5
Compare
|
I added a I also renamed I think it is ready to merge as soon as it is reviewed. |
|
This looks good to me. @bmu or @Calama-Consulting? |
|
I don't see, were |
|
If anybody wants something changed further then they can make a new issue for it. |
Python translation of NREL SPA code
|
There are no errors but unused imports (import warnings, import pytz) and unused variables Furthermore there some PEP8 issues but I don't know how strict we wanna be. |
|
@alorenzo175 |
|
I can change it quickly. |
Since the NREL SPA C code isn't included in the repo anymore, I thought I would translate the algorithm to python. The translation produces the same results as the C code. When using numpy arrays and operations, this code is just as fast as the cythonized C code. When using numba, the import can take a while because it has to compile, but it is much faster for subsequent calls. Numba can also release the GIL and can use multiple threads.
I also made some changes to the spa C cython files and spa function to take pressure and temperature inputs (instead of hard coded values) and also output apparent zenith and elevation.
This isn't quite ready for a merge yet; I still want to get delta_t automatically from the USNO instead of having a set value or making the user set it.